//
//  TrainingGoalItemCell.swift
//  DaRings
//
//  Created by 尹琼 on 2022/12/1.
//

import UIKit
import MYModule

open class TrainingGoalItemCell: CollectionViewCell {
    
    
    
    open var model: TrainingGoalItemModel? {
        
        didSet {
            
            titleLabel.text = model?.targetTitle
            descLabel.text = model?.desc

            if model?.isSelected == true {
                contentView.backgroundColor = model?.selectedTintColor
                
                titleLabel.textColor = UIColor.assist_FFFFFF
                descLabel.textColor = UIColor.assist_FFFFFF
            } else {
                titleLabel.textColor = UIColor.assist_222222
                descLabel.textColor = UIColor.assist_A9A9A9
                contentView.backgroundColor = UIColor.assist_EEEEEE
            }
            
        }
        
    }
    
    public let bgView = View()
    public let titleLabel = Label()
    public let descLabel = Label()
    
    
    open override func makeUI() {
        super.makeUI()
        
        titleLabel.font = Fonts.systemFont(ofSize: 16.0)
        descLabel.font = Fonts.systemFont(ofSize: 10.0)
        contentView.layer.cornerRadius = 8.0
        contentView.addSubview(bgView)
        bgView.addSubview(titleLabel)
        bgView.addSubview(descLabel)
        
        bgView.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.centerY.equalToSuperview()
        }
        
        titleLabel.snp.makeConstraints { make in
            make.top.equalToSuperview()
            make.centerX.equalToSuperview()
            make.right.lessThanOrEqualToSuperview()
            make.bottom.lessThanOrEqualToSuperview()
        }
        
        descLabel.snp.makeConstraints { make in
            make.centerX.equalToSuperview()
            make.top.equalTo(titleLabel.snp.bottom).offset(0.5)
            make.right.lessThanOrEqualToSuperview()
            make.bottom.lessThanOrEqualToSuperview()
        }
        
    }
    
    
    
}
